home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 8 / FM Towns Free Software Collection 8.iso / t_os / gpen32k / source / lib / osrc / fselmix.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-01  |  4.8 KB  |  230 lines

  1. /*
  2.         Free File Selector V0.21
  3.         ファイルセレクタ快適操作版
  4.                                 Copyright(C)1993 Okome
  5. */
  6.  
  7. #include    <stdio.h>
  8. #include    <string.h>
  9. #include    <dos.h>
  10. #include    <direct.h>
  11. #include    <EGB.H>
  12. #include    <MOS.H>
  13. #include    <kkstr2.h>
  14. #include    <Normlib.h>
  15. #include    <okome.h>
  16. #include    <col.h>
  17.  
  18. #define    FX4        340
  19. #define    FY4        220
  20. #define FX3        (FX4-1)
  21. #define    FY3        (FY4-1)
  22. #define FX2        (FX1+FX3)
  23. #define    FY2        (FY1+FY3)
  24.  
  25. extern char work[];
  26. static int FX1=120,FY1=80;
  27.  
  28. int WIN_MEN_bar(char *tt, int x1, int y1, int x2)
  29. {
  30.     boxbf( x1,y1,x1+x2,y1+15,cl8,cl9 );
  31.     boxf(x1,y1,x1+strlen(tt)*6+45,y1+15,cl8);
  32.     boxbf(x1,y1,x1+15,y1+15,cl8,cl4);
  33.     font12(x1+28,y1+13,tt,cl15);
  34.     return (0);
  35. }
  36.  
  37. static void dvsym(int drv)
  38. {
  39.     char w[2];
  40.     boxbf(FX1+30, FY1+20, FX1+60, FY1+37, cl8,cl15);
  41.     w[0]='A'+drv-1;
  42.     w[1]=0;
  43.     symbol(FX1+41,FY1+36, w, 16, cl8);
  44. }
  45.  
  46. static void dvpos(int s, int fx, struct _find_t fls[])
  47. {
  48.     int i,j;
  49.     boxf( FX1+8,FY1+44,FX2-24,FY2-24, cl8 );
  50.     boxbf( FX2-20,FY1+44,FX2-4,FY2-24, cl8, cl9 );
  51.     if (fx!=0)
  52.     {
  53.         j = FY1+44+(FY2-FY1-68)*(s/3)/((fx+2)/3);
  54.         i = j+(FY2-FY1-68)*8/((fx+2)/3);
  55.         if (i > FY2-24)
  56.             i = FY2-24;
  57.         boxbf( FX2-20,j,FX2-4, i, cl8, cl15 );
  58.         ubox2( FX2-19,j+1,FX2-5, i, cl15, cl8 );
  59.         for (i = 0; i<3*8 && s+i<fx; i++)
  60.         {
  61.             if ( fls[i+s].attrib & _A_SUBDIR )
  62.             {
  63.                 EGB_color( work, 0, cl14 );
  64.             }    else    {
  65.                 EGB_color( work, 0, cl15 );
  66.             }
  67.             print( FX1+9+(i % 3)*8*13, FY1+63+i/3*18, fls[i+s].name );
  68.         }
  69.     }    else    {
  70.         symbol(FX1+20,FY1+80,"File not found.",16,cl2);
  71.     }
  72. }
  73.  
  74. static int dvget( struct _find_t fls[])
  75. {
  76.     int fx = 0;
  77.     struct _find_t fla;
  78.     if (_dos_findfirst("*.*",_A_ARCH | _A_NORMAL | _A_SUBDIR | _A_RDONLY, &fla )==0)
  79.      {
  80.          do
  81.          {
  82.              fls[fx] = fla;
  83.              fx++;
  84.          }    while (_dos_findnext(&fla)==0 && fx<512);
  85.      }
  86.      return (fx);
  87. }
  88.  
  89. int OKM_fsel(char *fna, char *msg, unsigned int drv)
  90. {
  91.     int i, fx, s=0, r=1, mb, mx, my, dmx, dmy, p, k, t=1;
  92.     unsigned int edr, drb;
  93.     struct _find_t fls[512];
  94. /*    struct _diskfree_t fre;    */
  95. /*    char w[8];    */
  96.     p = EGB_getWritePage( 0, 0 );
  97.     KAN_getMode(&k);
  98.     KAN_setMode(0x20000);
  99.     EGB_writePage( work, 0 );
  100.     MOS_disp(0);
  101.     OKM_gth( FX1,FY1, FX2,FY2, 1 );
  102.     boxbf( FX1,FY1,FX2,FY2, cl0,cl15 );
  103.     WIN_MEN_bar( msg,FX1,FY1,FX3 );
  104.     boxb(FX1+20, FY1+20, FX1+70, FY1+37, cl8);
  105.     boxb( FX2-40, FY2-21, FX2-4, FY2-3, cl8 );
  106.     font12(FX2-33, FY2-5,"実行",cl8);
  107.     if (drv==0)
  108.     {
  109.         _dos_getdrive(&drv);
  110.     }    else    {
  111.         if (drv>='a' && drv<='z')
  112.             drv -= 'a'-1;
  113.         if (drv>='A' && drv<='Z')
  114.             drv -= 'A'-1;
  115.     }
  116.     _dos_setdrive(drv,&edr);
  117.     _dos_getdrive(&drv);
  118.     dvsym(drv);
  119. /*    _dos_getdiskfree( drv, &fre );
  120.     font12(FX1+100,FY1+36, _itoa( fre.*fre. ,w,10), cl8);    */
  121.     fx = dvget(fls);
  122.      dvpos(0, fx, fls);
  123.      boxb( FX1+16, FY2-20, FX1+128, FY2-2, cl8 );
  124.     MOS_disp(1);
  125.     do
  126.     {
  127.         MOS_rdpos(&mb,&mx,&my);
  128.         keyin(FX1+22,FY2-19,fna,12,cl15,cl8,t);
  129.         t = 0;
  130.         if (mb==1)
  131.         {
  132.             if (mx>FX1+8 && mx<FX2-24 && my>FY1+45 && my<FY2-25)
  133.             {    /*    ファイル    */
  134.                 do    {
  135.                     dmx = (mx-FX1-9)/(8*13);
  136.                     dmy = (my-FY1-45)/18;
  137.                     i = s + dmx + dmy*3;
  138.                     MOS_rdpos(&mb,&mx,&my);
  139.                 }    while (mb!=0);
  140.                 if (i<fx && mx>FX1+8 && mx<FX2-24 && my>FY1+45 && my<FY2-25)
  141.                 {
  142.                     if ((fls[i].attrib & _A_SUBDIR)==0)
  143.                     {
  144.                         strcpy(fna,fls[i].name);
  145.                         t = 1;
  146.                     }    else    {
  147.                         MOS_disp(0);
  148.                         _chdir(fls[i].name);
  149.                         s = 0;
  150.                         fx = dvget(fls);
  151.                          dvpos(0, fx, fls);
  152.                         MOS_disp(1);
  153.                     }
  154.                 }
  155.             }    else
  156.             if (mx>FX2-20 && mx<FX2-4 && my>FY1+44 && my<FY2-24)
  157.             {
  158.                 i = (((fx+2)/3)*(my-FY1-44)/(FY2-FY1-68))*3;
  159.                 if (i!=s)
  160.                 {
  161.                     s = i;
  162.                     MOS_disp(0);
  163.                      dvpos(s, fx, fls);
  164.                     MOS_disp(1);
  165.                 }
  166.             }
  167.             if (my>FY1+20 && my<FY1+37)
  168.             {
  169.                 if (mx>FX1+20 && mx<FX1+30)
  170.                 {
  171.                     do
  172.                     {
  173.                         drv--;
  174.                         if (drv==0)
  175.                             drv = edr;
  176.                         _dos_setdrive(drv,&edr);
  177.                         _dos_getdrive(&drb);
  178.                     }    while(drv!=drb);
  179.                     MOS_disp(0);
  180.                     dvsym(drv);
  181.                     fx = 0;
  182.                     MOS_disp(1);
  183.                     mbout(&i,&dmx,&dmy);
  184.                 }
  185.                 if (mx>FX1+60 && mx<FX1+70)
  186.                 {
  187.                     do
  188.                     {
  189.                         drv++;
  190.                         if (drv>edr)
  191.                             drv=1;
  192.                         _dos_setdrive(drv,&edr);
  193.                         _dos_getdrive(&drb);
  194.                     }    while(drv!=drb);
  195.                     MOS_disp(0);
  196.                     dvsym(drv);
  197.                     fx = 0;
  198.                     MOS_disp(1);
  199.                     mbout(&i,&dmx,&dmy);
  200.                 }
  201.                 if (mx>FX1+30 && mx<FX1+60)
  202.                 {
  203.                     MOS_disp(0);
  204.                     dvsym(drv);
  205.                     fx = dvget(fls);
  206.                     s = 0;
  207.                      dvpos(0, fx, fls);
  208.                     MOS_disp(1);
  209.                     mbout(&i,&dmx,&dmy);
  210.                 }
  211.             }
  212.             if (mx>FX2-40 && mx<FX2-4 && my>FY2-21 && my<FY2-3)
  213.             {
  214.                 r = 0;
  215.             }
  216.         }
  217.         if (mb==2 || (mb && mx>FX1 && mx<FX1+15 && my>FY1 && my<FY1+15))
  218.         {
  219.             r =-1;
  220.         }
  221.     }    while (r==1);
  222.     mbout(&mb,&mx,&my);
  223.     MOS_disp(0);
  224.     OKM_gth( FX1,FY1, FX2,FY2, 0 );
  225.     MOS_disp(1);
  226.     EGB_writePage( work, p );
  227.     KAN_setMode(k);
  228.     return (r);
  229. }
  230.